Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

348
Visualizações
Cannot create component with shallowMount, vm.$refs['VTU_COMPONENT'] is not defined

Not sure if it is a bug or If I'm doing something wrong.

I try to mount my main App component with shallowMount but it doesn't works. I get the following error message:

Cannot set properties of undefined (setting 'hasOwnProperty')

It happens when vue-test-utils try to mount the App Component:

...
var appRef = vm.$refs[MOUNT_COMPONENT_REF];
// we add `hasOwnProperty` so jest can spy on the proxied vm without throwing
appRef.hasOwnProperty = function (property) {
    return Reflect.has(appRef, property);
};
console.warn = warnSave;
var wrapper = createVueWrapper(app, appRef, setProps);
trackInstance(wrapper);
return wrapper; 
...

Here, MOUNT_COMPONENT_REF equals 'VTU_COMPONENT' and vm.$refs[MOUNT_COMPONENT_REF] isn't defined.

Minimal example

It is available online : https://codesandbox.io/s/prod-glitter-tnoyqt?file=/src/App.spec.js

App.vue

<template>
  <div id="a-test">
    {{ test }}
  </div>
</template>

<script>
export default {
  name: "App",
};
</script>

App.spec.js

import { shallowMount } from "@vue/test-utils";
import App from "@/App";

describe("App.vue", () => {
  test("Test that fails", async () => {
    const wrapper = shallowMount(App);
  });
});
about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

fixed if I upgrade to @vue/test-utils 2.0.0-rc.21

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda